package com.es.controller;

import com.es.domain.EsMetaResult;
import com.es.domain.Student;
import com.es.service.StudentServiceI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 描述:
 * es-meta-
 *
 * @author Derek
 * @create 2021-11-30 10:40
 */
@RestController
@RequestMapping("/student")
public class StudentRestfulController {

    @Autowired
    private StudentServiceI service;

    @GetMapping("/list")
    public EsMetaResult<List<Student>> list(HttpServletRequest request){
        EsMetaResult<List<Student>> result = service.list();
        System.out.println("hello");
        return result;
    }

    @PostMapping("/save")
    public EsMetaResult<String> save(@RequestBody Student student){
        EsMetaResult<String> result = service.save(student);
        return result;
    }
    @GetMapping("/get/{id}")
    public EsMetaResult<Student> get(@PathVariable("id") Integer id){
        EsMetaResult<Student> result = service.getById(id);
        return result;
    }
}
